<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        (function() {
            var a = b = 3;

        })();
        console.log(typeof a === "undefined"); //true
        console.log(typeof b === "undefined"); //false
        // 自执行函数执行形成一个私有的作用域，保护里面的私有变量不受外界的干扰
        // 2、var a = b = 3; 其实相当于 var a = 3; b = 3

        (function() {
            var a = b = 5;
        })();
        console.log(b); // 5
        console.log(a);//Uncaught ReferenceError: a is not defined
      
 

    </script>
</body>

</html>